import type { ThemeConfig } from '@/types/theme';
import React, { createContext, useContext } from 'react';

// 主题上下文
const ThemeContext = createContext<ThemeConfig>({});

// 主题上下文提供者
export const ThemeProvider: React.FC<{ children: React.ReactNode; theme: ThemeConfig }> = ({
  children,
  theme,
}) => {
  return <ThemeContext.Provider value={theme}>{children}</ThemeContext.Provider>;
};

// 使用主题的 Hook
export const useTheme = () => {
  const context = useContext(ThemeContext);
  if (context === undefined) {
    throw new Error('useTheme must be used within a ThemeProvider');
  }
  return context;
};

export default ThemeContext;
